home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / examples / xlib / hello next >
Encoding:
Text File  |  1991-08-05  |  1.0 KB  |  33 lines

  1. ;;; -*-Scheme-*-
  2.  
  3. (require 'xlib)
  4.  
  5. (define (hello-world)
  6.   (let* ((dpy (open-display))
  7.      (black (black-pixel dpy)) (white (white-pixel dpy))
  8.      (font (open-font dpy "*-new century schoolbook-bold-r*24*"))
  9.      (text (translate-text "Hello world!"))
  10.      (width (+ 2 (text-width font text '1-byte)))
  11.      (height (+ 2 (max-char-ascent font) (max-char-descent font)))
  12.      (win (create-window 'parent (display-root-window dpy)
  13.                'width width 'height height
  14.                'background-pixel white
  15.                'event-mask '(exposure button-press)))
  16.      (gc (create-gcontext 'window win 'background white
  17.                 'foreground black 'font font)))
  18.     (map-window win)
  19.     (unwind-protect
  20.      (handle-events dpy #t #f
  21.        (button-press
  22.     (lambda ignore #t))
  23.        (expose
  24.     (lambda ignore
  25.       (let ((x (truncate (/ (- (window-width win) width) 2)))
  26.         (y (truncate (/ (- (+ (window-height win)
  27.                       (max-char-ascent font))
  28.                    (max-char-descent font)) 2))))
  29.         (draw-poly-text win gc x y text '1-byte)) #f)))
  30.      (close-display dpy))))
  31.           
  32. (hello-world)
  33.